<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('抹灰实测报表提交')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <style>
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }

        input[type="number"] {
            -moz-appearance: textfield;

        }

    </style>

</head>


<body class="gray-bg">

<div class="main-content">
    <form id="form-add" class="form-horizontal">

        <input name="companyId" type="hidden" id="companyId"/>
        <input name="programId" type="hidden" id="programId"/>
        <input name="programName" type="hidden" id="programName"/>

        <h4 class="form-header h4"><span class="h4" th:text="${programName}"></span> &nbsp;&nbsp; 抹灰实测数据</h4>
        <div class="row">
            <div class="col-sm-12">
                <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i>
                </button>
                <button type="button" class="btn btn-white btn-sm" onclick="delColumn()"><i class="fa fa-minus">
                    删除</i></button>
                <div class="col-sm-12 select-table table-bordered">
                    <table id="bootstrap-table" style="table-layout: fixed;word-break: break-all"></table>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:src="@{/js/jquery.tmpl.js}"></script>

<script th:inline="javascript">

    /* 模块前缀url */
    var prefix = ctx + "concreteCheckManage";

    /* 初始化 数据 */
    var buildingNumber = [[${buildingNumber}]];
    var floorNumber = [[${floorNumber}]];
    var companyId = [[${companyId}]];
    var programId = [[${programId}]];
    var programName = [[${programName}]];
    // 定义数组
    var arr = new Array();
    var v = new Array();

    /* 初始化 方法 */
    $(function () {
        $("#companyId").val(companyId);
        $("#programId").val(programId);
        $("#programName").val(programName);

        var options = {
            pagination: false,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [
                            {
                                checkbox: true,
                                align: "center",
                            },

                            {
                                field: 'index',
                                valign: "middle",
                                align: 'center',
                                title: "序号",
                                width:50,
                                formatter: function (value, row, index) {
                                    var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                                    return columnIndex + $.table.serialNumber(index);
                                }
                            },

                            {
                                field: 'buildingNumber',
                                align: 'center',
                                title: '工程部位</br>楼号',
                                width:110,
                                formatter: function (value, row, index) {
                                    var html = '';
                                    html += '<select class="form-control building"  name="plasterCheck[' + index + '].buildingNumber" id="buildingNumber' + index + '"><option value="">请选择</option>';
                                    for (var i = 0; i < buildingNumber.length; i++) {
                                        html += '<option value="'+buildingNumber[i].id+'">'+buildingNumber[i].name+'</option>';
                                    }
                                    html += '</select>';
                                    return html;
                                }
                            },

                            {
                                field: 'floorNumber',
                                align: 'center',
                                title: '结构部位</br>楼层',
                                width:110,
                                formatter: function (value, row, index) {
                                    var html = '';
                                    html += '<select class="form-control floor"  name="plasterCheck[' + index + '].floorNumber" id="floorNumber' + index + '"><option value="">请选择</option>';
                                    for (var i = 0; i < floorNumber.length; i++) {
                                        html += "<option value='" + floorNumber[i].dictCode + "'>" + floorNumber[i].dictValue + "</option>";
                                    }
                                    html += '</select>';
                                    return html;
                                }
                            },

                            {
                                field: 'pouringTime',
                                align: 'center',
                                valign: "middle",
                                title: '施工完成时间',
                                width:120,
                                formatter: function (value, row, index) {
                                    var html = $.common.sprintf('<input class="form-control testff" type="text" placeholder="yyyy-MM-dd" id="pouringTime' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].pouringTime' + '"  autocomplete=\'off\'>', index, value);
                                    return html;
                                }
                            },
                        // 汇总项
                        {
                            field: 'totalCheck',
                            align: 'center',
                            title: '汇总项</br>检测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="totalCheck' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].totalCheck' + '"  autocomplete=\'off\' readonly>', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'totalActual',
                            align: 'center',
                            title: '汇总项</br>合格点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="totalActual' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].totalActual' + '"  autocomplete=\'off\' readonly>', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'totalRate',
                            align: 'center',
                            title: '汇总项</br>合格率',
                            width:110,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" type="text" name="'+'plasterCheck['+index+'].totalRate'+'" value="' + value + '" id="totalRate' + index+'" autocomplete="off" readonly>', index, value);
                                return html;
                            }
                        },


                        // 垂直度
                        {
                            field: 'verticalityCheck',
                            align: 'center',
                            title: '垂直度</br>检测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="verticalityCheck' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].verticalityCheck' + '"  autocomplete=\'off\' onblur="verticality(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'verticalityActual',
                            align: 'center',
                            title: '垂直度</br>实测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="verticalityActual' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].verticalityActual' + '"  autocomplete=\'off\' onblur="verticality(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'verticalityRate',
                            align: 'center',
                            title: '垂直度</br>合格率',
                            width:110,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" type="text" name="'+'plasterCheck['+index+'].verticalityRate'+'" value="' + value + '" id="verticalityRate' + index+'" autocomplete="off" readonly>', index, value);
                                return html;
                            }
                        },

                        // 平整度
                        {
                            field: 'planenessCheck',
                            align: 'center',
                            title: '平整度</br>检测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="planenessCheck' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].planenessCheck' + '"  autocomplete=\'off\' onblur="planenessRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'planenessActual',
                            align: 'center',
                            title: '平整度</br>实测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="planenessActual' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].planenessActual' + '"  autocomplete=\'off\' onblur="planenessRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'planenessRate',
                            align: 'center',
                            title: '平整度</br>合格率',
                            width:110,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" type="text" name="'+'plasterCheck['+index+'].planenessRate'+'" value="' + value + '" id="planenessRate' + index+'" autocomplete="off" readonly>', index, value);
                                return html;
                            }
                        },
                        // 阴阳角
                        {
                            field: 'angleCheck',
                            align: 'center',
                            title: '阴阳角</br>检测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="angleCheck' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].angleCheck' + '"  autocomplete=\'off\' onblur="angleRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'angleActual',
                            align: 'center',
                            title: '阴阳角</br>实测点数',
                            width:70,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="angleActual' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].angleActual' + '"  autocomplete=\'off\' onblur="angleRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'angleRate',
                            align: 'center',
                            title: '阴阳角</br>合格率',
                            width:110,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" type="text" name="'+'plasterCheck['+index+'].angleRate'+'" value="' + value + '" id="angleRate' + index+'" autocomplete="off" readonly>', index, value);
                                return html;
                            }
                        },
                        // 开间尺寸
                        {
                            field: 'bayCheck',
                            align: 'center',
                            title: '开间尺寸</br>检测点数',
                            width:80,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="bayCheck' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].bayCheck' + '"  autocomplete=\'off\' onblur="bayRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'bayActual',
                            align: 'center',
                            title: '开间尺寸</br>实测点数',
                            width:80,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="bayActual' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].bayActual' + '"  autocomplete=\'off\' onblur="bayRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'bayRate',
                            align: 'center',
                            title: '开间尺寸</br>合格率',
                            width:110,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" type="text" name="'+'plasterCheck['+index+'].bayRate'+'" value="' + value + '" id="bayRate' + index+'" autocomplete="off" readonly>', index, value);
                                return html;
                            }
                        },
                        // 地坪平整度
                        {
                            field: 'floorCheck',
                            align: 'center',
                            title: '地坪平整度</br>检测点数',
                            width:90,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="floorCheck' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].floorCheck' + '"  autocomplete=\'off\' onblur="floorRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'floorActual',
                            align: 'center',
                            title: '地坪平整度</br>实测点数',
                            width:90,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" onkeyup="value=value.replace(/[^\\d]/g,\'\')" id="floorActual' + index + '"  value="' + value + '" name="' + 'plasterCheck[' + index + '].floorActual' + '"  autocomplete=\'off\' onblur="floorRate(' + index + ')">', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'floorRate',
                            align: 'center',
                            title: '地坪平整度</br>合格率',
                            width:110,
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf('<input class="form-control" type="text" name="'+'plasterCheck['+index+'].floorRate'+'" value="' + value + '" id="floorRate' + index+'" autocomplete="off" readonly>', index, value);
                                return html;
                            }
                        },
                        {
                            field: 'testPerson',
                            align: 'center',
                            title: '检测人员',
                            width:100,
                            valign: "middle",
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf("<input class='form-control' type='text' name='plasterCheck[%s].testPerson' value='%s' autocomplete='off'>", index, value);
                                return html;
                            }
                        },
                        {
                            field: 'note',
                            align: 'center',
                            title: '备注',
                            width:100,
                            valign: "middle",
                            formatter: function (value, row, index) {
                                var html = $.common.sprintf("<input class='form-control' type='text' name='plasterCheck[%s].note' value='%s' autocomplete='off'>", index, value);
                                return html;
                            }
                        }
                        ]
        };
        $.table.init(options);
    });

    /* 初始化 日期*/
    function bindDatetimepicker() {
        $("input[name$='pouringTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true,
            pickerPosition: 'bottom-right'
        });
    }

    /* 添加行 */
    function addColumn() {

        var box = document.getElementsByClassName("building");
        var box1 = document.getElementsByClassName("floor");

        for (var i = 0; i < box.length; i++) {
            var ob = new Object();
            ob.building = $("#" + box[i].id).val();
            ob.floor = $("#" + box1[i].id).val();
            v.push(ob);
        }


        // 获取表格的所有内容行
        var count = $("#" + table.options.id).bootstrapTable('getData').length;
        sub.editColumn();

        $("#" + table.options.id).bootstrapTable('insertRow', {
            index: count,
            row: {
                index: $.table.serialNumber(count),
                buildingNumber: "",
                floorNumber: "",
                pouringTime: "",

                totalCheck: "",
                totalActual: "",
                totalRate: "",

                verticalityCheck: "",
                verticalityActual: "",
                verticalityRate: "",

                planenessCheck: "",
                planenessActual: "",
                planenessRate: "",

                sectionCheck: "",
                sectionActual: "",
                sectionRate: "",

                angleCheck: "",
                angleActual: "",
                angleRate: "",

                bayCheck: "",
                bayActual: "",
                bayRate: "",

                floorCheck: "",
                floorActual: "",
                floorRate: "",

                testPerson:"",
                note: "",
            }
        });
        /* 日期初始化 */
        bindDatetimepicker();

        for (var j = 0; j < v.length; j++) {
            $("#" + box[j].id).val(v[j].building);
            $("#" + box1[j].id).val(v[j].floor);

        }
        v = [];
    }

    /* 删除行:为了初始化日期,否则日期组件不生效 */
    function delColumn(column) {
        var subColumn = $.common.isEmpty(column) ? "index" : column;
        var ids = $.table.selectColumns(subColumn);
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (ids.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }

        var box = document.getElementsByClassName("building");
        var box1 = document.getElementsByClassName("floor");

        for (var i = 0; i < box.length; i++) {
            var ob = new Object();
            ob.building = $("#" + box[i].id).val();
            ob.floor = $("#" + box1[i].id).val();
            ob.id = i + 1;
            arr.push(ob);
        }
        sub.editColumn();


        $("#" + table.options.id).bootstrapTable('remove', {field: subColumn, values: ids});
        bindDatetimepicker();
        for (var k = 0; k < arr.length; k++) {

            for (var k1 = 0; k1 < row.length; k1++) {

                if (arr[k].id + "" == row[k1].index) {
                    arr.splice(k, 1);
                }
            }
        }

        for (var j = 0; j < arr.length; j++) {
            $("#" + box[j].id).val(arr[j].building);
            $("#" + box1[j].id).val(arr[j].floor);

        }

        arr = [];
    }

    /* 主子表-提交 */
    function submitHandler() {
        var data = $("#form-add").serializeArray();

        // 校验:不填写信息时保存
        if (data.length == 3) {
            $.modal.alertWarning("请完善报表信息");
            return;
        }

        // 校验:浇筑日期不能为空
        var pourTime = document.getElementsByClassName("testff");
        for (var i = 0; i < pourTime.length; i++) {
            var pourTimeVal = $("#" + pourTime[i].id).val();
            if(pourTimeVal == ''){
                $.modal.alertWarning("请填写浇筑日期");
                return;
            }
        }

        // $.operate.saveTab(prefix + '/savePlaster', data);

        var config = {
            url: prefix + '/savePlaster',
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍后...");
            },
            success: function (result) {
                if (typeof callback == "function") {
                    callback(result);
                }
                if (result.code == web_status.SUCCESS) {
                    var topWindow = $(window.parent.document);
                    var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel');
                    var $contentWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0].contentWindow;
                    $.modal.close();
                    $contentWindow.$.modal.msgSuccess(result.msg);
                    $contentWindow.$(".layui-layer-padding").removeAttr("style");
                    if ($contentWindow.table.options.type == table_type.bootstrapTable) {
                        $contentWindow.$.table.refreshPlasterCheck();
                    } else if ($contentWindow.table.options.type == table_type.bootstrapTreeTable) {
                        $contentWindow.$.treeTable.refreshPlasterCheck();
                    }
                    $.modal.closeTab();
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        };
        $.ajax(config)

    }

    /* 垂直度合格率 */
    function verticality(index) {
        if ($("#" + 'verticalityCheck' + index).val() != '' && $("#" + 'verticalityActual' + index).val() != '') {
            $("#" + 'verticalityRate' + index).attr("value",toPercent(parseInt($("#" + 'verticalityActual' + index).val()),parseInt($("#" + 'verticalityCheck' + index).val())))
        }else{
            $("#" + 'verticalityRate' + index).attr("value","")
        }

        // Step2 汇总项(检测点数、合格点数、合格率)

        // Step2.1  检测点数
        // 清除汇总检测点数
        $("#" + 'totalCheck' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalCheck' + index).val() == '' ? 0 : $("#" + 'totalCheck' + index).val();
        var verticalityCheck = $("#" + 'verticalityCheck' + index).val() == '' ? 0 : $("#" + 'verticalityCheck' + index).val();
        var planenessCheck = $("#" + 'planenessCheck' + index).val() == '' ? 0 : $("#" + 'planenessCheck' + index).val();
        var angleCheck = $("#" + 'angleCheck' + index).val() == '' ? 0 : $("#" + 'angleCheck' + index).val();
        var bayCheck = $("#" + 'bayCheck' + index).val() == '' ? 0 : $("#" + 'bayCheck' + index).val();
        var floorCheck = $("#" + 'floorCheck' + index).val() == '' ? 0 : $("#" + 'floorCheck' + index).val();
        // 汇总检测点数求和
        var totalCheck = parseInt(total) + parseInt(verticalityCheck)+ parseInt(planenessCheck) + parseInt(angleCheck)+ parseInt(bayCheck)+ parseInt(floorCheck);
        // 0转空处理
        var totalCheckSum = totalCheck == 0 ? '' : totalCheck;
        // 赋值
        $("#" + 'totalCheck' + index).attr("value",totalCheckSum)

        // Step2.2  合格点数
        // 清除汇总合格点数
        $("#" + 'totalActual' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalActual' + index).val() == '' ? 0 : $("#" + 'totalActual' + index).val();
        var verticalityActual = $("#" + 'verticalityActual' + index).val() == '' ? 0 : $("#" + 'verticalityActual' + index).val();
        var planenessActual = $("#" + 'planenessActual' + index).val() == '' ? 0 : $("#" + 'planenessActual' + index).val();
        var angleActual = $("#" + 'angleActual' + index).val() == '' ? 0 : $("#" + 'angleActual' + index).val();
        var bayActual = $("#" + 'bayActual' + index).val() == '' ? 0 : $("#" + 'bayActual' + index).val();
        var floorActual = $("#" + 'floorActual' + index).val() == '' ? 0 : $("#" + 'floorActual' + index).val();
        // 汇总检测点数求和
        var totalActual = parseInt(total) + parseInt(verticalityActual)+ parseInt(planenessActual)+  parseInt(angleActual)+ parseInt(bayActual)+ parseInt(floorActual);
        // 处理0值
        var totalActualSum = totalActual == 0 ? '' : totalActual;
        // 赋值
        $("#" + 'totalActual' + index).attr("value",totalActualSum)

        // Step2.2  合格率
        if ($("#" + 'totalCheck' + index).val() != '' && $("#" + 'totalActual' + index).val() != '') {
            $("#" + 'totalRate' + index).attr("value",toPercent(parseInt($("#" + 'totalActual' + index).val()),parseInt($("#" + 'totalCheck' + index).val())))
        }else{
            $("#" + 'totalRate' + index).attr("value","")
        }
    }

    /* 平整度合格率 */
    function planenessRate(index) {
        if ($("#" + 'planenessCheck' + index).val() != '' && $("#" + 'planenessActual' + index).val() != '') {
            $("#" + 'planenessRate' + index).attr("value",toPercent(parseInt($("#" + 'planenessActual' + index).val()),parseInt($("#" + 'planenessCheck' + index).val())))
        }else{
            $("#" + 'planenessRate' + index).attr("value","")
        }

        // Step2 汇总项(检测点数、合格点数、合格率)

        // Step2.1  检测点数
        // 清除汇总检测点数
        $("#" + 'totalCheck' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalCheck' + index).val() == '' ? 0 : $("#" + 'totalCheck' + index).val();
        var verticalityCheck = $("#" + 'verticalityCheck' + index).val() == '' ? 0 : $("#" + 'verticalityCheck' + index).val();
        var planenessCheck = $("#" + 'planenessCheck' + index).val() == '' ? 0 : $("#" + 'planenessCheck' + index).val();
        var angleCheck = $("#" + 'angleCheck' + index).val() == '' ? 0 : $("#" + 'angleCheck' + index).val();
        var bayCheck = $("#" + 'bayCheck' + index).val() == '' ? 0 : $("#" + 'bayCheck' + index).val();
        var floorCheck = $("#" + 'floorCheck' + index).val() == '' ? 0 : $("#" + 'floorCheck' + index).val();
        // 汇总检测点数求和
        var totalCheck = parseInt(total) + parseInt(verticalityCheck)+ parseInt(planenessCheck) + parseInt(angleCheck)+ parseInt(bayCheck)+ parseInt(floorCheck);
        // 0转空处理
        var totalCheckSum = totalCheck == 0 ? '' : totalCheck;
        // 赋值
        $("#" + 'totalCheck' + index).attr("value",totalCheckSum)

        // Step2.2  合格点数
        // 清除汇总合格点数
        $("#" + 'totalActual' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalActual' + index).val() == '' ? 0 : $("#" + 'totalActual' + index).val();
        var verticalityActual = $("#" + 'verticalityActual' + index).val() == '' ? 0 : $("#" + 'verticalityActual' + index).val();
        var planenessActual = $("#" + 'planenessActual' + index).val() == '' ? 0 : $("#" + 'planenessActual' + index).val();
        var angleActual = $("#" + 'angleActual' + index).val() == '' ? 0 : $("#" + 'angleActual' + index).val();
        var bayActual = $("#" + 'bayActual' + index).val() == '' ? 0 : $("#" + 'bayActual' + index).val();
        var floorActual = $("#" + 'floorActual' + index).val() == '' ? 0 : $("#" + 'floorActual' + index).val();
        // 汇总检测点数求和
        var totalActual = parseInt(total) + parseInt(verticalityActual)+ parseInt(planenessActual)+  parseInt(angleActual)+ parseInt(bayActual)+ parseInt(floorActual);
        // 处理0值
        var totalActualSum = totalActual == 0 ? '' : totalActual;
        // 赋值
        $("#" + 'totalActual' + index).attr("value",totalActualSum)

        // Step2.2  合格率
        if ($("#" + 'totalCheck' + index).val() != '' && $("#" + 'totalActual' + index).val() != '') {
            $("#" + 'totalRate' + index).attr("value",toPercent(parseInt($("#" + 'totalActual' + index).val()),parseInt($("#" + 'totalCheck' + index).val())))
        }else{
            $("#" + 'totalRate' + index).attr("value","")
        }
    }

    /* 阴阳角合格率 */
    function angleRate(index) {
        if ($("#" + 'angleCheck' + index).val() != '' && $("#" + 'angleActual' + index).val() != '') {
            $("#" + 'angleRate' + index).attr("value",toPercent(parseInt($("#" + 'angleActual' + index).val()),parseInt($("#" + 'angleCheck' + index).val())))
        }else{
            $("#" + 'angleRate' + index).attr("value","")
        }

        // Step2 汇总项(检测点数、合格点数、合格率)

        // Step2.1  检测点数
        // 清除汇总检测点数
        $("#" + 'totalCheck' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalCheck' + index).val() == '' ? 0 : $("#" + 'totalCheck' + index).val();
        var verticalityCheck = $("#" + 'verticalityCheck' + index).val() == '' ? 0 : $("#" + 'verticalityCheck' + index).val();
        var planenessCheck = $("#" + 'planenessCheck' + index).val() == '' ? 0 : $("#" + 'planenessCheck' + index).val();
        var angleCheck = $("#" + 'angleCheck' + index).val() == '' ? 0 : $("#" + 'angleCheck' + index).val();
        var bayCheck = $("#" + 'bayCheck' + index).val() == '' ? 0 : $("#" + 'bayCheck' + index).val();
        var floorCheck = $("#" + 'floorCheck' + index).val() == '' ? 0 : $("#" + 'floorCheck' + index).val();
        // 汇总检测点数求和
        var totalCheck = parseInt(total) + parseInt(verticalityCheck)+ parseInt(planenessCheck) + parseInt(angleCheck)+ parseInt(bayCheck)+ parseInt(floorCheck);
        // 0转空处理
        var totalCheckSum = totalCheck == 0 ? '' : totalCheck;
        // 赋值
        $("#" + 'totalCheck' + index).attr("value",totalCheckSum)

        // Step2.2  合格点数
        // 清除汇总合格点数
        $("#" + 'totalActual' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalActual' + index).val() == '' ? 0 : $("#" + 'totalActual' + index).val();
        var verticalityActual = $("#" + 'verticalityActual' + index).val() == '' ? 0 : $("#" + 'verticalityActual' + index).val();
        var planenessActual = $("#" + 'planenessActual' + index).val() == '' ? 0 : $("#" + 'planenessActual' + index).val();
        var angleActual = $("#" + 'angleActual' + index).val() == '' ? 0 : $("#" + 'angleActual' + index).val();
        var bayActual = $("#" + 'bayActual' + index).val() == '' ? 0 : $("#" + 'bayActual' + index).val();
        var floorActual = $("#" + 'floorActual' + index).val() == '' ? 0 : $("#" + 'floorActual' + index).val();
        // 汇总检测点数求和
        var totalActual = parseInt(total) + parseInt(verticalityActual)+ parseInt(planenessActual)+  parseInt(angleActual)+ parseInt(bayActual)+ parseInt(floorActual);
        // 处理0值
        var totalActualSum = totalActual == 0 ? '' : totalActual;
        // 赋值
        $("#" + 'totalActual' + index).attr("value",totalActualSum)

        // Step2.2  合格率
        if ($("#" + 'totalCheck' + index).val() != '' && $("#" + 'totalActual' + index).val() != '') {
            $("#" + 'totalRate' + index).attr("value",toPercent(parseInt($("#" + 'totalActual' + index).val()),parseInt($("#" + 'totalCheck' + index).val())))
        }else{
            $("#" + 'totalRate' + index).attr("value","")
        }
    }

    /* 开间尺寸合格率 */
    function bayRate(index) {
        if ($("#" + 'bayCheck' + index).val() != '' && $("#" + 'bayActual' + index).val() != '') {
            $("#" + 'bayRate' + index).attr("value",toPercent(parseInt($("#" + 'bayActual' + index).val()),parseInt($("#" + 'bayCheck' + index).val())))
        }else{
            $("#" + 'bayRate' + index).attr("value","")
        }

        // Step2 汇总项(检测点数、合格点数、合格率)

        // Step2.1  检测点数
        // 清除汇总检测点数
        $("#" + 'totalCheck' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalCheck' + index).val() == '' ? 0 : $("#" + 'totalCheck' + index).val();
        var verticalityCheck = $("#" + 'verticalityCheck' + index).val() == '' ? 0 : $("#" + 'verticalityCheck' + index).val();
        var planenessCheck = $("#" + 'planenessCheck' + index).val() == '' ? 0 : $("#" + 'planenessCheck' + index).val();
        var angleCheck = $("#" + 'angleCheck' + index).val() == '' ? 0 : $("#" + 'angleCheck' + index).val();
        var bayCheck = $("#" + 'bayCheck' + index).val() == '' ? 0 : $("#" + 'bayCheck' + index).val();
        var floorCheck = $("#" + 'floorCheck' + index).val() == '' ? 0 : $("#" + 'floorCheck' + index).val();
        // 汇总检测点数求和
        var totalCheck = parseInt(total) + parseInt(verticalityCheck)+ parseInt(planenessCheck) + parseInt(angleCheck)+ parseInt(bayCheck)+ parseInt(floorCheck);
        // 0转空处理
        var totalCheckSum = totalCheck == 0 ? '' : totalCheck;
        // 赋值
        $("#" + 'totalCheck' + index).attr("value",totalCheckSum)

        // Step2.2  合格点数
        // 清除汇总合格点数
        $("#" + 'totalActual' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalActual' + index).val() == '' ? 0 : $("#" + 'totalActual' + index).val();
        var verticalityActual = $("#" + 'verticalityActual' + index).val() == '' ? 0 : $("#" + 'verticalityActual' + index).val();
        var planenessActual = $("#" + 'planenessActual' + index).val() == '' ? 0 : $("#" + 'planenessActual' + index).val();
        var angleActual = $("#" + 'angleActual' + index).val() == '' ? 0 : $("#" + 'angleActual' + index).val();
        var bayActual = $("#" + 'bayActual' + index).val() == '' ? 0 : $("#" + 'bayActual' + index).val();
        var floorActual = $("#" + 'floorActual' + index).val() == '' ? 0 : $("#" + 'floorActual' + index).val();
        // 汇总检测点数求和
        var totalActual = parseInt(total) + parseInt(verticalityActual)+ parseInt(planenessActual)+  parseInt(angleActual)+ parseInt(bayActual)+ parseInt(floorActual);
        // 处理0值
        var totalActualSum = totalActual == 0 ? '' : totalActual;
        // 赋值
        $("#" + 'totalActual' + index).attr("value",totalActualSum)

        // Step2.2  合格率
        if ($("#" + 'totalCheck' + index).val() != '' && $("#" + 'totalActual' + index).val() != '') {
            $("#" + 'totalRate' + index).attr("value",toPercent(parseInt($("#" + 'totalActual' + index).val()),parseInt($("#" + 'totalCheck' + index).val())))
        }else{
            $("#" + 'totalRate' + index).attr("value","")
        }
    }

    /* 地坪平整度合格率 */
    function floorRate(index) {
        if ($("#" + 'floorCheck' + index).val() != '' && $("#" + 'floorActual' + index).val() != '') {
            $("#" + 'floorRate' + index).attr("value",toPercent(parseInt($("#" + 'floorActual' + index).val()),parseInt($("#" + 'floorCheck' + index).val())))
        }else{
            $("#" + 'floorRate' + index).attr("value","")
        }

        // Step2 汇总项(检测点数、合格点数、合格率)

        // Step2.1  检测点数
        // 清除汇总检测点数
        $("#" + 'totalCheck' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalCheck' + index).val() == '' ? 0 : $("#" + 'totalCheck' + index).val();
        var verticalityCheck = $("#" + 'verticalityCheck' + index).val() == '' ? 0 : $("#" + 'verticalityCheck' + index).val();
        var planenessCheck = $("#" + 'planenessCheck' + index).val() == '' ? 0 : $("#" + 'planenessCheck' + index).val();
        var angleCheck = $("#" + 'angleCheck' + index).val() == '' ? 0 : $("#" + 'angleCheck' + index).val();
        var bayCheck = $("#" + 'bayCheck' + index).val() == '' ? 0 : $("#" + 'bayCheck' + index).val();
        var floorCheck = $("#" + 'floorCheck' + index).val() == '' ? 0 : $("#" + 'floorCheck' + index).val();
        // 汇总检测点数求和
        var totalCheck = parseInt(total) + parseInt(verticalityCheck)+ parseInt(planenessCheck) + parseInt(angleCheck)+ parseInt(bayCheck)+ parseInt(floorCheck);
        // 0转空处理
        var totalCheckSum = totalCheck == 0 ? '' : totalCheck;
        // 赋值
        $("#" + 'totalCheck' + index).attr("value",totalCheckSum)

        // Step2.2  合格点数
        // 清除汇总合格点数
        $("#" + 'totalActual' + index).attr("value",0);
        // 空转0处理
        var total = $("#" + 'totalActual' + index).val() == '' ? 0 : $("#" + 'totalActual' + index).val();
        var verticalityActual = $("#" + 'verticalityActual' + index).val() == '' ? 0 : $("#" + 'verticalityActual' + index).val();
        var planenessActual = $("#" + 'planenessActual' + index).val() == '' ? 0 : $("#" + 'planenessActual' + index).val();
        var angleActual = $("#" + 'angleActual' + index).val() == '' ? 0 : $("#" + 'angleActual' + index).val();
        var bayActual = $("#" + 'bayActual' + index).val() == '' ? 0 : $("#" + 'bayActual' + index).val();
        var floorActual = $("#" + 'floorActual' + index).val() == '' ? 0 : $("#" + 'floorActual' + index).val();
        // 汇总检测点数求和
        var totalActual = parseInt(total) + parseInt(verticalityActual)+ parseInt(planenessActual)+  parseInt(angleActual)+ parseInt(bayActual)+ parseInt(floorActual);
        // 处理0值
        var totalActualSum = totalActual == 0 ? '' : totalActual;
        // 赋值
        $("#" + 'totalActual' + index).attr("value",totalActualSum)

        // Step2.2  合格率
        if ($("#" + 'totalCheck' + index).val() != '' && $("#" + 'totalActual' + index).val() != '') {
            $("#" + 'totalRate' + index).attr("value",toPercent(parseInt($("#" + 'totalActual' + index).val()),parseInt($("#" + 'totalCheck' + index).val())))
        }else{
            $("#" + 'totalRate' + index).attr("value","")
        }
    }

    /* 小数点后两位百分比*/
    function toPercent(num, total) {
        return (Math.round(num / total * 10000) / 100.00 + "%");

    }

</script>
</body>
</html>
</script>